package com.market.cart.server.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.market.common.log.annotation.Log;
import com.market.common.log.enums.BusinessType;
import com.market.common.security.annotation.RequiresPermissions;
import com.market.cart.common.domain.TDeliveryAddress;
import com.market.cart.server.service.ITDeliveryAddressService;
import com.market.common.core.web.controller.BaseController;
import com.market.common.core.utils.poi.ExcelUtil;
import com.market.common.core.web.page.TableDataInfo;
import com.market.common.core.domain.Result;

/**
 * 【请填写功能名称】Controller
 *
 * @author market
 * @date 2024-02-26
 */
@RestController
@RequestMapping("/address")
public class TDeliveryAddressController extends BaseController
{
    @Autowired
    private ITDeliveryAddressService tDeliveryAddressService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("cart:address:list")
    @GetMapping("/list")
    public Result<TableDataInfo> list(TDeliveryAddress tDeliveryAddress)
    {
        startPage();
        List<TDeliveryAddress> list = tDeliveryAddressService.selectTDeliveryAddressList(tDeliveryAddress);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("cart:address:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDeliveryAddress tDeliveryAddress)
    {
        List<TDeliveryAddress> list = tDeliveryAddressService.selectTDeliveryAddressList(tDeliveryAddress);
        ExcelUtil<TDeliveryAddress> util = new ExcelUtil<TDeliveryAddress>(TDeliveryAddress.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("cart:address:query")
    @GetMapping(value = "/{addressId}")
    public Result getInfo(@PathVariable("addressId") Long addressId)
    {
        return success(tDeliveryAddressService.selectTDeliveryAddressByAddressId(addressId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("cart:address:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody TDeliveryAddress tDeliveryAddress)
    {
        return toAjax(tDeliveryAddressService.insertTDeliveryAddress(tDeliveryAddress));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("cart:address:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody TDeliveryAddress tDeliveryAddress)
    {
        return toAjax(tDeliveryAddressService.updateTDeliveryAddress(tDeliveryAddress));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("cart:address:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{addressIds}")
    public Result remove(@PathVariable Long[] addressIds)
    {
        return toAjax(tDeliveryAddressService.deleteTDeliveryAddressByAddressIds(addressIds));
    }
}
